package com.biao.cloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GateWayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_biao",     // 路由的ID，没有固定规则但要求唯一，建议配合服务名
                r -> r.path("/guonei")      // 访问 http://localhost:9527/guonei 就会转发到下面的地址
                        .uri("http://news.baidu.com/guonei")).build();

        return routes.build();
    }
}